package com.mspbots.sync.wise.controller;

import com.fasterxml.jackson.databind.JsonNode;
import com.mspbots.sync.wise.service.WiseUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.util.Map;

/**
 * com.mspbots.sync.wise.controller.UsersController
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2020/2/3
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "users")
public class UsersController {
    private final WiseUserService wiseUserService;

    @GetMapping("page")
    public Flux<JsonNode> getPage(@RequestParam Map<String, String> params) {
        Assert.notNull(params.get("tenantId"), () -> "Search param tenant id not null.");
        return this.wiseUserService.getUsers(params);
    }
}
